//*************************************************************************************
/** \file task_radio.h
 *    This file contains a class which transmits packages of data from the sensors
 *    in an AVR One-Wire weather station system. The radio task gets averages of
 *    readings which have been saved up by sensor tasks and transmits a set of
 *    averages in a burst in order to save power. 
 *
 *  Revisions:
 *    \li 12-26-2007 JRR Original file
 *    \li 12-30-2007 JRR Corrected spelling of Fahrenheit
 *    \li 01-21-2008 JRR Modified to use average wind readings
 *    \li 03-20-2009 JRR Made compatible with new sensors and global debugging
 */
//*************************************************************************************

/// This define prevents this file from being included more than once in a *.cc file
#ifndef _TASK_RADIO_H_
#define _TASK_RADIO_H_


/** This define specifies the character that comes between data items in a line of
 *  weather data transmitted by the radio. Default is a space character. */
#define WX_SEPARATOR		" "

/** This define specifies how many readings to save up to be sent each time the radio
 *  modem is turned on. */
#define RDGS_PER_TRANSMIT	3


//-------------------------------------------------------------------------------------
/** This class contains a task which reads data from the weather sensors and stores 
 *  the data up in queues, then sends bunches of averaged and queued readings 
 *  periodically. 
 */

class task_radio : public stl_task
{
	protected:
		m9XStream* the_radio;				///< Pointer to the radio modem object
		task_timer* the_timer;				///< Pointer to real-time counting timer
		base_text_serial* the_debug_port;	///< Pointer to a radio/serial port
		task_wind* the_wind_task;			///< Pointer to task for wind sensors
		task_temphumid* the_sht15_task;		///< Pointer to temperature/humidity task
		task_temperature* the_ds1822_task;	///< Pointer to temperature only task
		task_battery* the_batt_task;		///< Pointer to charge controller task
		time_stamp temp_time_stamp;			///< Holder for temporary time values

	public:
		// The constructor creates a new radio task object
		task_radio (m9XStream*, task_wind*, task_temphumid*, task_temperature*, 
					task_battery*, task_timer&, time_stamp);

		// The run method is where the task actually performs its function
		char run (char);
};

#endif // _TASK_RADIO_H_
